<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="TOKN">﻿</span><span class="COMM">/*
<span class='line'>  2</span> Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
<span class='line'>  3</span> For licensing, see LICENSE.html or http://ckeditor.com/license
<span class='line'>  4</span> */</span><span class="WHIT">
<span class='line'>  5</span>
<span class='line'>  6</span> </span><span class="COMM">/**
<span class='line'>  7</span>  * @fileOverview Defines the {@link CKEDITOR.tools} object, which contains
<span class='line'>  8</span>  *		utility functions.
<span class='line'>  9</span>  */</span><span class="WHIT">
<span class='line'> 10</span>
<span class='line'> 11</span> </span><span class="COMM">/**
<span class='line'> 12</span>  * Utility functions.
<span class='line'> 13</span>  * @namespace
<span class='line'> 14</span>  * @example
<span class='line'> 15</span>  */</span><span class="WHIT">
<span class='line'> 16</span> </span><span class="NAME">CKEDITOR.tools</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 19</span> 	 * Copy the properties from one object to another. By default, properties
<span class='line'> 20</span> 	 * already present in the target object &lt;strong>are not&lt;/strong> overwritten.
<span class='line'> 21</span> 	 * @param {Object} target The object to be extended.
<span class='line'> 22</span> 	 * @param {Object} source[,souce(n)] The objects from which copy
<span class='line'> 23</span> 	 *		properties. Any number of objects can be passed to this function.
<span class='line'> 24</span> 	 * @param {Boolean} [overwrite] Indicates that properties already present
<span class='line'> 25</span> 	 *		in the target object must be overwritten. This must be the last
<span class='line'> 26</span> 	 *		parameter in the function call.
<span class='line'> 27</span> 	 * @returns {Object} the extended object (target).
<span class='line'> 28</span> 	 * @example
<span class='line'> 29</span> 	 * // Create the sample object.
<span class='line'> 30</span> 	 * var myObject =
<span class='line'> 31</span> 	 * {
<span class='line'> 32</span> 	 *     prop1 : true
<span class='line'> 33</span> 	 * };
<span class='line'> 34</span> 	 *
<span class='line'> 35</span> 	 * // Extend the above object with two properties.
<span class='line'> 36</span> 	 * CKEDITOR.tools.extend( myObject,
<span class='line'> 37</span> 	 *     {
<span class='line'> 38</span> 	 *         prop2 : true,
<span class='line'> 39</span> 	 *         prop3 : true
<span class='line'> 40</span> 	 *     } );
<span class='line'> 41</span> 	 *
<span class='line'> 42</span> 	 * // Alert "prop1", "prop2" and "prop3".
<span class='line'> 43</span> 	 * for ( var p in myObject )
<span class='line'> 44</span> 	 *     alert( p );
<span class='line'> 45</span> 	 */</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">	</span><span class="NAME">extend</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">target</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">argsLength</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments.length</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">			</span><span class="NAME">overwrite</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">argsLength</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 50</span>
<span class='line'> 51</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">overwrite</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'boolean'</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">			</span><span class="NAME">argsLength</span><span class="PUNC">--</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT">			</span><span class="NAME">overwrite</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 55</span>
<span class='line'> 56</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">argsLength</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">source</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 59</span>
<span class='line'> 60</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">propertyName</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">source</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">			</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">overwrite</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">propertyName</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">					</span><span class="NAME">target</span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">propertyName</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">source</span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">propertyName</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 66</span>
<span class='line'> 67</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 69</span>
<span class='line'> 70</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 71</span> 	 * Creates an object which is an instance of a class which prototype is a
<span class='line'> 72</span> 	 * predefined object. All properties defined in the source object are
<span class='line'> 73</span> 	 * automatically inherited by the resulting object, including future
<span class='line'> 74</span> 	 * changes to it.
<span class='line'> 75</span> 	 * @param {Object} source The source object to be used as the prototype for
<span class='line'> 76</span> 	 *		the final object.
<span class='line'> 77</span> 	 * @returns {Object} The resulting copy.
<span class='line'> 78</span> 	 */</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">	</span><span class="NAME">prototypedCopy</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">source</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">copy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">		</span><span class="NAME">copy.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">source</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">copy</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 86</span>
<span class='line'> 87</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 88</span> 	 * Checks if an object is an Array.
<span class='line'> 89</span> 	 * @param {Object} object The object to be checked.
<span class='line'> 90</span> 	 * @type Boolean
<span class='line'> 91</span> 	 * @returns &lt;i>true&lt;/i> if the object is an Array, otherwise &lt;i>false&lt;/i>.
<span class='line'> 92</span> 	 * @example
<span class='line'> 93</span> 	 * alert( CKEDITOR.tools.isArray( [] ) );      // "true"
<span class='line'> 94</span> 	 * alert( CKEDITOR.tools.isArray( 'Test' ) );  // "false"
<span class='line'> 95</span> 	 */</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">	</span><span class="NAME">isArray</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">object</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">!</span><span class="NAME">object</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">object</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>100</span>
<span class='line'>101</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>102</span> 	 * Transforms a CSS property name to its relative DOM style name.
<span class='line'>103</span> 	 * @param {String} cssName The CSS property name.
<span class='line'>104</span> 	 * @returns {String} The transformed name.
<span class='line'>105</span> 	 * @example
<span class='line'>106</span> 	 * alert( CKEDITOR.tools.cssStyleToDomStyle( 'background-color' ) );  // "backgroundColor"
<span class='line'>107</span> 	 * alert( CKEDITOR.tools.cssStyleToDomStyle( 'float' ) );             // "cssFloat"
<span class='line'>108</span> 	 */</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">	</span><span class="NAME">cssStyleToDomStyle</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">cssName</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">cssName</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'float'</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'cssFloat'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">cssName.replace</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="REGX">/-./g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">match</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">				</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">					</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">match.substr</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toUpperCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>121</span>
<span class='line'>122</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>123</span> 	 * Replace special HTML characters in a string with their relative HTML
<span class='line'>124</span> 	 * entity values.
<span class='line'>125</span> 	 * @param {String} text The string to be encoded.
<span class='line'>126</span> 	 * @returns {String} The encode string.
<span class='line'>127</span> 	 * @example
<span class='line'>128</span> 	 * alert( CKEDITOR.tools.htmlEncode( 'A > B & C &lt; D' ) );  // "A &amp;gt; B &amp;amp; C &amp;lt; D"
<span class='line'>129</span> 	 */</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">	</span><span class="NAME">htmlEncode</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">standard</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">span</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">CKEDITOR.dom.element</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="STRN">'span'</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">			</span><span class="NAME">span.setText</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">span.getHtml</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>138</span>
<span class='line'>139</span> </span><span class="WHIT">		</span><span class="NAME">this.htmlEncode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">standard</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="STRN">'>'</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'>'</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">			</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">			</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">				</span><span class="COMM">// WebKit does't encode the ">" character, which makes sense, but</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">				</span><span class="COMM">// it's different than other browsers.</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">				</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">standard</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="REGX">/>/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'&gt;'</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">			</span><span class="NAME">standard</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span>
<span class='line'>148</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.htmlEncode</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>150</span>
<span class='line'>151</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>152</span> 	 * Gets a unique number for this CKEDITOR execution session. It returns
<span class='line'>153</span> 	 * progressive numbers starting at 1.
<span class='line'>154</span> 	 * @function
<span class='line'>155</span> 	 * @returns {Number} A unique number.
<span class='line'>156</span> 	 * @example
<span class='line'>157</span> 	 * alert( CKEDITOR.tools.&lt;b>getNextNumber()&lt;/b> );  // "1" (e.g.)
<span class='line'>158</span> 	 * alert( CKEDITOR.tools.&lt;b>getNextNumber()&lt;/b> );  // "2"
<span class='line'>159</span> 	 */</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">	</span><span class="NAME">getNextNumber</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">last</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="NAME">last</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>168</span>
<span class='line'>169</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>170</span> 	 * Creates a function override.
<span class='line'>171</span> 	 * @param {Function} originalFunction The function to be overridden.
<span class='line'>172</span> 	 * @param {Function} functionBuilder A function that returns the new
<span class='line'>173</span> 	 *		function. The original function reference will be passed to this
<span class='line'>174</span> 	 *		function.
<span class='line'>175</span> 	 * @returns {Function} The new function.
<span class='line'>176</span> 	 * @example
<span class='line'>177</span> 	 * var example =
<span class='line'>178</span> 	 * {
<span class='line'>179</span> 	 *     myFunction : function( name )
<span class='line'>180</span> 	 *     {
<span class='line'>181</span> 	 *         alert( 'Name: ' + name );
<span class='line'>182</span> 	 *     }
<span class='line'>183</span> 	 * };
<span class='line'>184</span> 	 *
<span class='line'>185</span> 	 * example.myFunction = CKEDITOR.tools.override( example.myFunction, function( myFunctionOriginal )
<span class='line'>186</span> 	 *     {
<span class='line'>187</span> 	 *         return function( name )
<span class='line'>188</span> 	 *             {
<span class='line'>189</span> 	 *                 alert( 'Override Name: ' + name );
<span class='line'>190</span> 	 *                 myFunctionOriginal.call( this, name );
<span class='line'>191</span> 	 *             };
<span class='line'>192</span> 	 *     });
<span class='line'>193</span> 	 */</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">	</span><span class="NAME">override</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">originalFunction</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">functionBuilder</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">functionBuilder</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">originalFunction</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>198</span>
<span class='line'>199</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>200</span> 	 * Executes a function after specified delay.
<span class='line'>201</span> 	 * @param {Function} func The function to be executed.
<span class='line'>202</span> 	 * @param {Number} [milliseconds] The amount of time (millisecods) to wait
<span class='line'>203</span> 	 *		to fire the function execution. Defaults to zero.
<span class='line'>204</span> 	 * @param {Object} [scope] The object to hold the function execution scope
<span class='line'>205</span> 	 *		(the "this" object). By default the "window" object.
<span class='line'>206</span> 	 * @param {Object|Array} [args] A single object, or an array of objects, to
<span class='line'>207</span> 	 *		pass as arguments to the function.
<span class='line'>208</span> 	 * @param {Object} [ownerWindow] The window that will be used to set the
<span class='line'>209</span> 	 *		timeout. By default the current "window".
<span class='line'>210</span> 	 * @returns {Object} A value that can be used to cancel the function execution.
<span class='line'>211</span> 	 * @example
<span class='line'>212</span> 	 * CKEDITOR.tools.&lt;b>setTimeout(
<span class='line'>213</span> 	 *     function()
<span class='line'>214</span> 	 *     {
<span class='line'>215</span> 	 *         alert( 'Executed after 2 seconds' );
<span class='line'>216</span> 	 *     },
<span class='line'>217</span> 	 *     2000 )&lt;/b>;
<span class='line'>218</span> 	 */</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">	</span><span class="NAME">setTimeout</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">func</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">milliseconds</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scope</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">args</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ownerWindow</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">ownerWindow</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">			</span><span class="NAME">ownerWindow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>223</span>
<span class='line'>224</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">scope</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT">			</span><span class="NAME">scope</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ownerWindow</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>226</span>
<span class='line'>227</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ownerWindow.setTimeout</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">			</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT">			</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">args</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT">					</span><span class="NAME">func.apply</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">scope</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">concat</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">args</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">				</span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">					</span><span class="NAME">func.apply</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">scope</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">			</span><span class="NAME">milliseconds</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>237</span>
<span class='line'>238</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>239</span> 	 * Remove spaces from the start and the end of a string. The following
<span class='line'>240</span> 	 * characters are removed: space, tab, line break, line feed.
<span class='line'>241</span> 	 * @function
<span class='line'>242</span> 	 * @param {String} str The text from which remove the spaces.
<span class='line'>243</span> 	 * @returns {String} The modified string without the boundary spaces.
<span class='line'>244</span> 	 * @example
<span class='line'>245</span> 	 * alert( CKEDITOR.tools.trim( '  example ' );  // "example"
<span class='line'>246</span> 	 */</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">	</span><span class="NAME">trim</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT">		</span><span class="COMM">// We are not using \s because we don't want "non-breaking spaces" to be caught.</span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">trimRegex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">str.replace</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">trimRegex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>256</span>
<span class='line'>257</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>258</span> 	 * Remove spaces from the start (left) of a string. The following
<span class='line'>259</span> 	 * characters are removed: space, tab, line break, line feed.
<span class='line'>260</span> 	 * @function
<span class='line'>261</span> 	 * @param {String} str The text from which remove the spaces.
<span class='line'>262</span> 	 * @returns {String} The modified string excluding the removed spaces.
<span class='line'>263</span> 	 * @example
<span class='line'>264</span> 	 * alert( CKEDITOR.tools.ltrim( '  example ' );  // "example "
<span class='line'>265</span> 	 */</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">	</span><span class="NAME">ltrim</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">		</span><span class="COMM">// We are not using \s because we don't want "non-breaking spaces" to be caught.</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">trimRegex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/^[ \t\n\r]+/g</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">str.replace</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">trimRegex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>275</span>
<span class='line'>276</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>277</span> 	 * Remove spaces from the end (right) of a string. The following
<span class='line'>278</span> 	 * characters are removed: space, tab, line break, line feed.
<span class='line'>279</span> 	 * @function
<span class='line'>280</span> 	 * @param {String} str The text from which remove the spaces.
<span class='line'>281</span> 	 * @returns {String} The modified string excluding the removed spaces.
<span class='line'>282</span> 	 * @example
<span class='line'>283</span> 	 * alert( CKEDITOR.tools.ltrim( '  example ' );  // "  example"
<span class='line'>284</span> 	 */</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">	</span><span class="NAME">rtrim</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT">		</span><span class="COMM">// We are not using \s because we don't want "non-breaking spaces" to be caught.</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">trimRegex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/[ \t\n\r]+$/g</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">str.replace</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">trimRegex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>294</span>
<span class='line'>295</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>296</span> 	 * Returns the index of an element in an array.
<span class='line'>297</span> 	 * @param {Array} array The array to be searched.
<span class='line'>298</span> 	 * @param {Object} entry The element to be found.
<span class='line'>299</span> 	 * @returns {Number} The (zero based) index of the first entry that matches
<span class='line'>300</span> 	 *		the entry, or -1 if not found.
<span class='line'>301</span> 	 * @example
<span class='line'>302</span> 	 * var letters = [ 'a', 'b', 'c' ];
<span class='line'>303</span> 	 * alert( CKEDITOR.tools.indexOf( letters, 'b' ) );  "1"
<span class='line'>304</span> 	 */</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">	</span><span class="NAME">indexOf</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">entry</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">array.length</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">array</span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">entry</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">				</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>314</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>315</span>
<span class='line'>316</span> </span><span class="COMM">// PACKAGER_RENAME( CKEDITOR.tools )</span><span class="WHIT">
<span class='line'>317</span> </span></pre></body></html>
